"""universe URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.urls import include, path, re_path
from django.views.static import serve

from account import views as user_views
from mood import views as mood_views

urlpatterns = (
    [
        path('', mood_views.Mood.as_view(), name='index'),
        path('admin/', admin.site.urls),
        path('mood/', include('mood.urls')),
        path('blog/', include('blog.urls')),
        path('comment/', include('comment.urls')),
        path('profile/', include('account.urls')),
        # 关注好友
        path('friend/', include('friendship.urls')),

        # 用户相关
        # path('register/', user_views.register, name='register'),
        path('register/', user_views.Register.as_view(), name='register'),
        path('login/', user_views.login, name='login'),
        path('login/sms/', user_views.login_sms, name='login_sms'),
        path('send/sms/', user_views.send_sms, name='send_sms'),
        path('image/code/', user_views.image_code, name='image_code'),
        path('logout/', user_views.logout, name='logout'),

        # path('profile/', user_views.profile, name='profile'),

        re_path(r'^ckeditor/', include('ckeditor_uploader.urls')),

        re_path(r'^static/(?P<path>.*)$', serve, {"document_root": settings.STATIC_ROOT}, name='static'),
        re_path(r'^media/(?P<path>.*)$', serve, {"document_root": settings.MEDIA_ROOT}, name='media'),
        path('inbox/notifications/', include('notifications.urls', namespace='notifications')),
        path('notice/', include('navigation.urls')),

        # path('blog/', include(blog_urls)),
    ]
)

if settings.DEBUG:
    pass
else:
    # 全局 404 页面配置（django 会自动调用这个变量）
    handler404 = 'navigation.views.page_not_found'
    handler500 = 'navigation.views.page_error'

#     import debug_toolbar
#
#     urlpatterns = [
#                       re_path(r'^__debug__/', include(debug_toolbar.urls)),
#                   ] + urlpatterns

urlpatterns += staticfiles_urlpatterns()
